import request from "@/axios/request";
import url from "@/axios/url";
import admin from "@/router/admin";
const { mesUrl, adminUrl, minioUrl } = url();
// 导出url
export const exportUrl = `${mesUrl}mesProdBom/export`;
// 分页查询
export function getList (params = {}) {
  return request({
    url: `${mesUrl}mesProdBom`,
    method: "get",
    params,
  });
}
// 新增
export function rowCreate (data = {}) {
  return request({
    url: `${mesUrl}mesProdBom/addTree`,
    method: "post",
    data,
  });
}
// 修改
export function rowUpdate (data = {}) {
  return request({
    url: `${mesUrl}mesProdBom`,
    method: "put",
    data,
  });
}
// 删除
export function rowDel (id) {
  return request({
    url: `${mesUrl}mesProdBom/${id}`,
    method: "put",
  });
}
// 详情
export function rowDetail (id) {
  return request({
    url: `${mesUrl}mesProdBom/info/${id}`,
    method: "get",
  });
}

// 查询物料编码列表
export function getMaterialCodeList () {
  return request({
    url: `${adminUrl}baseGoods`,
    method: "get",
  });
}
// 查询状态列表
export function getBomStatusList () {
  return request({
    url: `${adminUrl}dict/type/bom_status`,
    method: "get",
  });
}
// 查询物料类型编码列表
export function getMaterialTypeValueList () {
  return request({
    url: `${adminUrl}dict/type/material_type`,
    method: "get",
  });
}
// 查询制造方式编码列表
export function getManufactureMethodValueList () {
  return request({
    url: `${adminUrl}dict/type/manufacture_method`,
    method: "get",
  });
}
// 查询二级及以下级别的bom
export function getTreeList (params) {
  return request({
    url: `${mesUrl}mesProdBom/getTreeList`,
    method: "get",
    params,
  });
}
// 工艺建模-升级
export function upgrade (data) {
  return request({
    url: `${mesUrl}mesProdBom/upgrade`,
    method: "post",
    data,
  });
}
// 工艺建模-停用
export function stop (data) {
  return request({
    url: `${mesUrl}mesProdBom/stop`,
    method: "post",
    data,
  });
} // 工艺建模-发布
export function publish (data) {
  return request({
    url: `${mesUrl}mesProdBom/start`,
    method: "post",
    data,
  });
}
// 复制
export function copy (data = {}) {
  return request({
    url: `${mesUrl}mesProdBom/copy`,
    method: "post",
    data,
  });
}
// 成品和半成品查询
export function pageBcpAndCp (params) {
  return request({
    url: `${adminUrl}baseGoods/pageBcpAndCp`,
    method: "get",
    params,
  });
}
// 原材料查询
export function pageYCL (params) {
  return request({
    url: `${adminUrl}baseGoods/pageYCL`,
    method: "get",
    params,
  });
}
// 获取bom版本下拉
export function getBomVersionList (params) {
  return request({
    url: `${mesUrl}mesProdBom/getBomVersionList`,
    method: "get",
    params,
  });
}

export function importData (data = {}) {
  return request({
    url: `${mesUrl}mesProdBom/import`,
    method: 'POST',
    data,
    headers: {
      'Content-Type': 'multipart/form-data',
    }
  })
}
export const downloadTemplateUrl = `${minioUrl}/mes-template/产品BOM上传模版.xls`

